<?
/*
 * scrumbrella - Scrum board.
 *
 * Copyright (C) 2009  Gustavo N. Borgoni <gborgoni@voicemedia.com.ar>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

include("include/user.php");
include("layout_config.php");

require_once("PHPTAL.php");

$temp = new PHPTAL('templates/login.xhtml');

$temp->theme 	   = 'themes/default/login.css';
$temp->lock  	   = "themes/default/images/login_img.jpg";
$temp->title 	   = $layout_project_name." | "._("Login");
$temp->user 	   = _("User").": ";
$temp->password    = _("Password").": ";
$temp->identified  = "0";
$temp->buttom      = _("Login");

if ($_SERVER['REQUEST_METHOD'] == "POST") {
	$user = $_REQUEST['user'];
	$pass = $_REQUEST['pass'];

	$userID = user_login($user, $pass);
	if ($userID > 0) {
		session_start();

		$_SESSION['sessid'] 	  = $userID;
		$_SESSION['access_level'] = user_get_accesslevel($userID);

		header("Location: main.php");
	} else {
		$temp->message 	  = _("Authentification failed");
		$temp->identified = 1;
	}
}

try 
{
	echo $temp->execute();
}

catch(Exception $e)
{
	echo $e;
}

?>
